#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 500001
#define inf 0x7f7f7f7f
#define Rep(i,a,b) for(int i=(a);i<=(b);++i)
#define Per(i,a,b) for(int i=(a);i>=(b);--i)
int n,a[maxn],cnt,vis[maxn],ans,l,live[maxn];
struct node {
	int l,r;
} p[maxn];
inline void Read(int &x) {
	int s=0;
	bool w=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')w=ch=='-'?1:w,ch=getchar();
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	x=w?-s:s;
}
int main() {
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	Read(n);
	memset(p,255,sizeof(p));
	Rep(i,1,n) {
		Read(a[i]);
		live[i]=1;
		if(a[i]==a[i-1])
			p[cnt].r=i;
		else
			p[++cnt].l=i,p[cnt].r=i,vis[cnt]=0;
	}
	while(ans<n) {
		bool out=1;
		Rep(i,1,cnt) {
			if(vis[i])continue;
			printf("%d ",p[i].l);
			out=0;
			ans++;
			live[p[i].l]=0;
			p[i].l++;
			if(p[i].l>p[i].r) {
				vis[i]=1;
			}
		}
		Rep(i,1,cnt) {
			if(vis[i]) {
				int x=i,y=i;
				Per(j,i,1)
					if(!vis[j]) {
						x=j;
						break;
					}
				Rep(k,i,cnt)
					if(!vis[k]) {
						y=k;
						break;
					}
				if(a[p[x].l]!=a[p[i].l]||a[p[y].l]!=a[p[i].l])
					break;
				else if(x!=y)p[x].r=p[y].r,vis[y]=1;
			}
		}
		if(out)break;
		printf("\n");
	}
	Rep(i,1,n)if(live[i])printf("%d ",i);
	return 0;
}

